package com.xique.door.api.factory;


import com.xique.common.core.domain.R;
import com.xique.door.api.RemoteAppLoginLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 *
 * @author xique
 */
@Component
public class RemoteAppLoginLogFallbackFactory implements FallbackFactory<RemoteAppLoginLogService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteAppLoginLogFallbackFactory.class);

    @Override
    public RemoteAppLoginLogService create(Throwable throwable)
    {
        log.error("登录服务调用失败:{}", throwable.getMessage());
        return new RemoteAppLoginLogService()
        {
            @Override
            public R<Boolean> saveLoginLog(String username, String status, String message, String platform) {
                return R.fail("保存访问记录失败:" + throwable.getMessage());
            }
        };

    }
}
